#include<stdio.h>
int main()
{
	int m;
	int n;
	int r;
	scanf("%d %d",&m,&n);
	while(r=m%n)
	{
		m=n;
		n=r;
		printf("%d",n);
	}
	
}

